function showDetail(uid){
	var tabPanel = window.parent.abc();
	if(!Ext.isEmpty(tabPanel)){
		var tabs = tabPanel.getComponent(uid);
		if(!tabs){
			tabs =	tabPanel.add({
		      	id:uid,
		        title:'车辆详情', 
		        html : '<iframe id="myframe" name="myframe" scrolling="auto" frameborder="0" width="100%" height="100%" allowtransparency="yes"  src="carInfo/showCarDetail.action?uid='+uid+'"></iframe>',
		        closable:true
			});
		}
		tabPanel.setActiveTab(tabs);
	}
};
Ext.onReady(function(){
	Ext.QuickTips.init();
	var store = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
							url : 'carInfo/getCarBaseInfo.action'
						}),
				reader : new Ext.data.JsonReader({
							totalProperty : 'totalcount',
							root : 'root'
						}, [{
									name : 'uid'
								}, {
									name : 'carUnit'
								}, {
									name : 'fileNum'
								},{
									name:'artificialNum'
								},{
									name:'licensePlate'
								},{
									name:'vehicleModel'
								},{
									name:'prepareDate'
								},{
									name:'vehicleType'
								},{
									name:'useProperty'
								},{
									name:'detail'
								}]),
								autoLoad:true
			});
			
	var pagesize_combo = new Ext.form.ComboBox({
				name : 'pagesize',
				hiddenName : 'pagesize',
				typeAhead : true,
				triggerAction : 'all',
				lazyRender : true,
				mode : 'local',
				store : new Ext.data.ArrayStore({
							fields : ['value', 'text'],
							data : [[10, '10条/页'], [20, '20条/页'],
									[50, '50条/页'], [100, '100条/页'],
									[250, '250条/页'], [500, '500条/页']]
						}),
				valueField : 'value',
				displayField : 'text',
				value : '50',
				editable : false,
				width : 85
			});
	var number = parseInt(pagesize_combo.getValue());
	pagesize_combo.on("select", function(comboBox) {
				bbar.pageSize = parseInt(comboBox.getValue());
				number = parseInt(comboBox.getValue());
				store.reload({
							params : {
								start : 0,
								limit : bbar.pageSize
							}
						});
			});
	var bbar = new Ext.PagingToolbar({
				pageSize : number,
				store : store,
				displayInfo : true,
				displayMsg : '显示{0}条到{1}条,共{2}条',
				plugins : new Ext.ux.ProgressBarPager(), // 分页进度条
				emptyMsg : "没有符合条件的记录",
				items : ['-', '&nbsp;&nbsp;', pagesize_combo]
			});
			
	var sm = new Ext.grid.CheckboxSelectionModel();
	var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), sm, {
				header : 'uid',
				dataIndex : 'uid',
				hidden:true
			}, {
				header : '车辆单位',
				dataIndex : 'carUnit',
				sortable : true
			}, {
				header : '档号',
				dataIndex : 'fileNum'
			},{
				header:'自编号码',
				dataIndex:'artificialNum'
			},{
				header:'牌照号码',
				dataIndex:'licensePlate'
			},{
				header:'车辆型号',
				dataIndex:'vehicleModel'
			},{
				header:'编制日期',
				dataIndex:'prepareDate'
			},{
				header:'类别',
				dataIndex:'vehicleType'
			},{
				header:'使用性质',
				dataIndex:'useProperty'
			},{
				header:'查看详情',
				dataIndex:'detail'
			}]);
			
	var carGrid = new Ext.grid.GridPanel({
				height : 510,
				store : store,
				region : 'center',
				loadMask : {
					msg : '正在加载表格数据,请稍等...'
				},
				stripeRows : true,
				frame : false,
				border:false,
				cm : cm,
				sm : sm,
				bbar : bbar,
				tbar:[{
					text:'增加',
					iconCls:'addIcon',
					scale : 'medium',
					handler:function(){
						var tabPanel = window.parent.abc();
						if(!Ext.isEmpty(tabPanel)){
							var tabs = tabPanel.getComponent("addCarBaseInfo");
							if(!tabs){
								tabs =	tabPanel.add({
						       		id:'addCarBaseInfo',
						            title:'添加车辆信息', 
						            html : '<iframe id="myframe" name="myframe" scrolling="auto" frameborder="0" width="100%" height="100%" allowtransparency="yes"  src="createCarInfo01.jsp"></iframe>',
						            closable:true
								});
							}
							tabPanel.setActiveTab(tabs);
						}
					}
				},'-',{
					text:'删除',
					iconCls:'deleteIcon',
					scale : 'medium',
					handler:function(){
						var rows = carGrid.getSelectionModel().getSelections();
						if(Ext.isEmpty(rows)){
							Ext.Msg.alert('提示','请选择要删除的车辆信息');
							return;
						}
						
						Ext.Msg.confirm('确认删除','确定要删除所选择的车辆吗？',function(e){
							if(e=='no'){
								return;
							}else{
								var uids = [];
								Ext.each(rows,function(row){
									uids.push(row.get("uid"));
								});
								Ext.Ajax.request({
									url:'carInfo/delCarInfo.action',
									params:{
										uids:uids.join('|')
									},
									success:function(response){
										var txt = Ext.util.JSON.decode(response.responseText);
										if(txt.result=="success"){
											Ext.Msg.alert('提示','删除成功');
											store.reload();
										}else{
											Ext.Msg.alert('提示','删除失败，请联系管理员');
										}
									},
									failure:function(){
										Ext.Msg.alert("提示","删除失败，请联系管理员");
									}
								});
							}
						})
					}
				},'->',{
					text:'刷新',
					iconCls:'',
					scale:'medium',
					pressed:true,
					handler:function(){
						store.reload();
					}
				}]
			});	
	
	
	
	/**
	 * 布局
	 */
	var viewport = new Ext.Viewport({
				layout : 'fit',
				items : [carGrid]
			});
});